import { BasicColumn, FormSchema } from '/@/components/Table';
import { DictCodeEnum, getDictItems, getDictItemMap } from '/@/utils/dict';

// 系统内置字典数据
const systemConfigDict = getDictItems(DictCodeEnum.SYSTEM_CONFIG);
const systemConfigDictMap = getDictItemMap(DictCodeEnum.SYSTEM_CONFIG);

export const columns: BasicColumn[] = [
  {
    title: '参数名称',
    dataIndex: 'configName',
  },
  {
    title: '参数键名',
    dataIndex: 'configKey',
  },
  {
    title: '参数键值',
    dataIndex: 'configValue',
  },
  {
    title: '系统内置',
    dataIndex: 'configType',
    dictFormat: systemConfigDictMap,
  },
  {
    title: '备注',
    dataIndex: 'remark',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'configName',
    label: '参数名称',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'configKey',
    label: '参数键名',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'configType',
    label: '系统内置',
    component: 'Select',
    componentProps: {
      options: systemConfigDict,
    },
    colProps: { span: 6 },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: 'ID',
    component: 'Input',
    show: false,
  },
  {
    field: 'configName',
    label: '参数名称',
    component: 'Input',
    required: true,
  },
  {
    field: 'configKey',
    label: '参数键名',
    component: 'Input',
    required: true,
  },
  {
    field: 'configValue',
    label: '参数键值',
    component: 'Input',
    required: true,
  },
  {
    field: 'configType',
    label: '系统内置',
    component: 'RadioButtonGroup',
    defaultValue: 1,
    componentProps: {
      options: systemConfigDict,
    },
    required: true,
  },
  {
    field: 'remark',
    label: '备注',
    component: 'InputTextArea',
  },
];
